/*
 * util.c
 *
 *  Created on: 21-oct-2008
 *      Author: hector
 */

#include "util.h"

void getPreviousDirectory(const char * path, char *dest)
{
    //printf("getPreviousDirectory %s\n", path);
    if (strlen(path) == 1)
       strcpy(dest,"/");

    else
    {

        int len;
        int index;
        len = strlen(path);
        for (index = len - 1; index >= 0; index--)
        {

            if (path[index] == '/')
                break;
        }

        if (index == -1)
            index = 1;


        if (index == 1)
        {
            strcpy(dest, "/");
        }
        else
        {
            memcpy(dest, path, index);
            dest[index] = '\0';
        }


    }
}

void getDescriptionFromPath(const char * path, char *dest)
{

    int len;
    int index;
    len = strlen(path);
    for (index = len; index >= 0; index--)
    {
        if (path[index] == '/')
            break;
    }

    memcpy(dest, &path[index + 1], len - index);
    //result[index] = '\0';


}




